package com.wmmb.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.wmmb.entity.Announcement;
import com.wmmb.entity.Member;
import com.wmmb.service.AnnouncementService;
import com.wmmb.service.UtilService;

public class AnnouncementAction extends BaseAction implements SessionAware {

	private static final long serialVersionUID = -6921602692322750271L;

	private Map<String, Object> session;

	private AnnouncementService announcementService;
	private UtilService utilService;
	
	private List<Announcement> announcements;
	private Member member;

	public String watchAnnouncement() {
		Long eaId = member.getEaId();
		member = (Member)session.get("memberInfo");
		member.setEaId(eaId);
//		ThirdAccount account = utilService.getEaIdByNameId(member);
		Announcement announcement = new Announcement();
		announcement.setEaId(eaId);
		announcements = announcementService
				.watchAnnouncement(announcement);
		if (announcements == null) {
			return "toNullAnnouncement";
		}
		if (announcements.size() == 0) {
			return "toNullAnnouncement";
		}
		return "toWatchAnnouncement";
	}

	public AnnouncementService getAnnouncementService() {
		return announcementService;
	}

	public void setAnnouncementService(AnnouncementService announcementService) {
		this.announcementService = announcementService;
	}

	public UtilService getUtilService() {
		return utilService;
	}

	public void setUtilService(UtilService utilService) {
		this.utilService = utilService;
	}

	public List<Announcement> getAnnouncements() {
		return announcements;
	}

	public void setAnnouncements(List<Announcement> announcements) {
		this.announcements = announcements;
	}

	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

}
